<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="base.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" type="text/css" href="style/top.css"/>
    <link rel="stylesheet" type="text/css" href="style/main.css"/>
	<link rel="stylesheet" type="text/css" href="style/footer.css"/>
    <script type="text/javascript" src="script/kindeditor/kindeditor-min.js"></script>
	<script type="text/javascript" src="script/jquery.js"></script>
	<script type="text/javascript" src="script/jquery.scrollTo-min.js"></script>
	<script type="text/javascript" src="script/jquery.validate.js"></script>
	<script type="text/javascript">
		/*
		function replycheck() {
			var content = document.getElementById("reply_area").value;
			var msg = document.getElementById("errormsg");
			if(content.length > 8) {
				return true;
			} else {
				msg.innerHTML = "请输入认真回复不要灌水";
				return false;
			}
		}*/
	
		$().ready(function() {
			$("#reply_form").validate({
				rules: {
					content: {
						required: true,
						minlength: 10
					}
				},
				messages: {
					content: {
						required: "内容不能为空",
						minlength: "最短10个字符，请认真填写！"
					}
				}
			
			});
			
			$('#post_reply').click(function(){
					$.scrollTo( '#f_pst', 1600, { 
					queue:true,
					onAfter:function(){
						
					}
				});
			});
		
		});
		
		function reply(pid) {
			repid = document.getElementById("repid");
			repid.value = pid;
			$.scrollTo('#f_pst',800);
		}
		
		function gopst() {
			$.scrollTo('#f_pst',800);
		}
		
		function gotop() {
			$.scrollTo('#hd',800);
		}
		KE.show({
				id : 'content',
				resizeMode : 1,
				allowPreviewEmoticons : false,
				syncType : 'auto',
				allowUpload : false,
				items : [
				'fontname', 'fontsize', '|', 'textcolor', 'bgcolor', 'bold', 'italic', 'underline',
				'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
				'insertunorderedlist', '|', 'emoticons', 'image', 'link']
			});
	</script>
	<title>编程之友BBS-${article.blocks.name }-${article.name }</title>

</head>
<body>
	<!-- head开始 -->
	<%@ include file="template/head.jsp" %>
	<!-- head结束 -->
    <div style="margin-top: 10px">
    </div>
    <!-- 主体部分开始 -->
    
	<div id="wp" class="wp">
		<!-- 导航开始 -->
    	<div id="pt" class="bm cl">
            <div id="ct" class="ct2_a wp cl">
                <div class="z">
                    <a class="nvhm" title="首页" href="index.jspx">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
                    <em>›</em>
                 	<a href="blocks.jspx?_method=show&id=${article.blocks.id }">${article.blocks.name }</a>
                 	<em>›</em>
                 	${article.name }
                </div>
            </div>
       	</div>
       	<!-- 导航结束 -->
	
    	<div id="ct" class="wp cl">
        	<div class="mn">
            	<!-- 发帖回帖开始 -->
                <div id="pgt" class="pgs mbm cl">
                	<div class="pg">
             			<c:if test="${sessionScope.page.currentPage gt 7 and sessionScope.page.totlePages gt 10}">
                       		<a href="article.jspx?_method=show&id=${sessionScope.article.id }&page=1">1..</a>
                       	</c:if>
               			<c:forEach items="${sessionScope.page.slider }" var="x">
               				<c:choose>
                				<c:when test="${sessionScope.page.currentPage eq x }">
                					<strong>${x }</strong>
                				</c:when>
                				<c:otherwise>
                					<a href="article.jspx?_method=show&id=${sessionScope.article.id }&page=${x }">${x }</a>
                				</c:otherwise>
               				</c:choose>
               			</c:forEach>
               			<c:if test="${sessionScope.page.currentPage+4 lt sessionScope.page.totlePages and sessionScope.page.totlePages gt 10}">
               				<a href="article.jspx?_method=show&id=${sessionScope.article.id }&page=${sessionScope.page.totlePages }">..${sessionScope.page.totlePages }</a>
               			</c:if>
               			<c:if test="${not sessionScope.page.last }">
               				<a class="nxt" href="article.jspx?_method=show&id=${sessionScope.article.id }&page=${sessionScope.page.currentPage+1 }">下一页</a> 
               			</c:if>
                    </div>
                    <span class="pgb y">
                    	<a href="article.jspx?_method=show&id=${sessionScope.article.id }">返回</a>
                    </span>
                    <a id="newspecial" title="发新帖" href="index.jspx?_method=create&id=${article.blocks.id }" >
                    	<img alt="发新帖" src="images/pn_post.png" />
                    </a>
                    <a id="post_reply" title="回复" href="javascript:gopst();" >
                    	<img alt="回复" src="images/pn_reply.png" />
                    </a>
                    
                </div>
                <!-- 发帖回帖结束 -->
                <div class="clear">
                </div>
                <!-- -->
                <div id="postlist" class="pl bm bmw" style="border: none;">
                	<!-- 帖子开始 -->
                	<c:if test="${sessionScope.page.currentPage eq '1' }">
                    <div id="article_${sessionScope.article.id }" style="margin:10px 0;border:1px solid #7AC2E4;min-height:320px;">
                    	<div class="e_title">
                        	<h1 class="thread_title ts">
                            	<a href="article.jspx?_method=show&id=${sessionScope.article.id }" >${sessionScope.article.name }</a>
                                
                            </h1> 
                        </div>
						<div>
                        
                        
                            <div class="pls firsttop">
                                <div class="e_lg">
                                    <!-- 用户头像信息开始 -->
                                    <div style="width: 80px; float: left">
                                        <div class="avatar" style="margin: 10px 0;">
                                            <a href="user.jspx?_method=show?&id=${sessionScope.article.user.id }">
                                                <img src="upload/${sessionScope.article.user.headpic }" />
                                            </a>
                                        </div>
                                        <p style="margin-top:0px;margin-left:0px;text-align:center;word-break:no-wrap;">
                                            <a href="user.jspx?_method=show?&id=${sessionScope.article.user.id }">${sessionScope.article.user.username }</a>
                                        </p>
                                    </div>
                                    <!-- 用户头像信息结束 -->
                                    <div class="box_data" style="margin-top: 10px;*+margin-top:-12px;">
                                    	<p>
                                    	
                                    	</p>
                                    	<p>
                                    	</p>
                                    </div>
                                    <div class="clear">
                                    </div>
                                </div>
                            </div>
                            
                            
                            <div class="pi">
                            	<!-- 帖子发表时间开始 -->
                                <div class="pi">
                                    <div class="pti">
                                        <strong class="y">
                                          	 楼主
                                        </strong>
                                        <div class="pdbt"> </div>
                                        <div class="authi">
                                            <em id="authorposton1" class="z">${sessionScope.article.createdate }</em>
                                        </div>
                                    </div>
                                    
                                </div>
                                <!-- 帖子发表时间结束 -->
                            </div>
                            
                            
                            <div class="pct">
                                <!-- 帖子内容开始 -->
                                <div class="pct">
                                    <div class="pcb">
                                        <div class="t_fsz">
                                            <h1 style="margin-top: 2px; font-size: 18px;">
                                                ${sessionScope.article.name }
                                            </h1>
                                          <div class="content">
                                          	${sessionScope.article.content }
                                          </div>
                                        </div>
                                    </div>
                                </div>
                                <!-- 帖子内容结束 -->
                            </div>
                            
                            <div class="plc pdlr10">
                            	<div class="po">
                                	<div class="pob cl">
                                    	<p>
                                        	<em>
                                            	<a class="fastre" href="javascript:gopst();">回复</a>
                                            </em>
                                            <c:if test="${not empty sessionScope.user}">
                                            <em>
                                            	<a class="fastre" href="article.jspx?_method=collection&id=${sessionScope.article.id }">收藏</a>
                                            </em>
                                            </c:if>
                                            <c:if test="${sessionScope.user.role eq '2' }">
                                            	<a class="adel" href="article.jspx?_method=delete&id=${sessionScope.article.id }&userid=${sessionScope.user.id}&bid=${sessionScope.article.blocks.id}">删除</a>
                                            </c:if>
                                            <a href="javascript:gotop();">返回顶部</a>
                                        </p>
                                    </div>
                                </div>
                            </div>
                            
  						</div>
                    </div>
                    </c:if>
                    <!-- 帖子结束 -->
                    <c:set var="i" value="0"></c:set>
					<c:forEach items="${sessionScope.article.replyList }" var="reply" varStatus="state">
					<!-- 回复列表开始 -->
					<div id="replay_${sessionScope.reply.id }" style="margin:10px 0;border:1px solid #7AC2E4;min-height:320px;">
						<!-- 回复发表时间开始 -->
						<div class="pi">
							<div class="pti">
								<strong class="y">
									<c:out value="${(sessionScope.page.currentPage-1)*(sessionScope.page.pageSize)+state.count }"/>楼
								</strong>
								<div class="pdbt"> </div>
								<c:choose>
									<c:when test="${reply.state}">
										<c:if test="${reply.pid eq -1 }">
											<div class="authi">
												<em id="authorposton${reply.user.id }" class="z"><span>${reply.user.username }</span>回复于 ${reply.createdate }</em>
											</div>
										</c:if>
										<c:if test="${reply.pid != -1 }">
											<div class="authi">
												<em id="authorposton${reply.user.id }" class="z"><span>${reply.user.username }</span>回复 <a class="red" href="#">${reply.pid}楼</a> 于 ${reply.createdate }</em>
											</div>
										</c:if>
									</c:when>
									<c:otherwise>
										<div class="authi">
											<em class="z"><span>空</span></em>
										</div>
									
									</c:otherwise>
								</c:choose>
							</div>
							
						</div>
						<!-- 回复发表时间结束 -->
						<!-- 回复内容开始 -->
						<div class="pct">
							<div class="pcb">
								<div class="t_fsz">
								<c:choose>
									<c:when test="${reply.state }">
									  	<div class="content">
											${reply.content }
										</div>
									</c:when>
									<c:otherwise>
										<div class="content">
											<h2 style="text-align:center; font-size: 20px; color=red;">该回复已被删除！</h2>
										</div>
									</c:otherwise>
								</c:choose>
								</div>
							</div>
						</div>
						<!-- 回复内容结束 -->
                        
                        <div class="plc pdlr10">
                            	<div class="po">
                                	<div class="pob cl">
                                    	<p>
                                        	<em>
                                            	<a class="fastre" href="javascript:reply(${(sessionScope.page.currentPage-1)*(sessionScope.page.pageSize)+state.count } )">回复</a>
                                            </em>
                                            <a href="javascript:gotop();">返回顶部</a>
                                        </p>
                                    </div>
                                </div>
                            </div>
                        
					</div>
					<!-- 回复列表结束 -->
                    </c:forEach>
                </div>
                <!-- -->
                <div class="clear"></div>
                <!-- 发帖回帖开始 -->
                <div id="pgt" class="pgs mbm cl">
                	<div class="pg">
             			<c:if test="${sessionScope.page.currentPage gt 7 and sessionScope.page.totlePages gt 10}">
                       		<a href="article.jspx?_method=show&id=${sessionScope.article.id }&page=1">1..</a>
                       	</c:if>
               			<c:forEach items="${sessionScope.page.slider }" var="x">
               				<c:choose>
                				<c:when test="${sessionScope.page.currentPage eq x }">
                					<strong>${x }</strong>
                				</c:when>
                				<c:otherwise>
                					<a href="article.jspx?_method=show&id=${sessionScope.article.id }&page=${x }">${x }</a>
                				</c:otherwise>
               				</c:choose>
               			</c:forEach>
               			<c:if test="${sessionScope.page.currentPage+4 lt sessionScope.page.totlePages and sessionScope.page.totlePages gt 10}">
               				<a href="article.jspx?_method=show&id=${sessionScope.article.id }&page=${sessionScope.page.totlePages }">..${sessionScope.page.totlePages }</a>
               			</c:if>
               			<c:if test="${not sessionScope.page.last }">
               				<a class="nxt" href="article.jspx?_method=show&id=${sessionScope.article.id }&page=${sessionScope.page.currentPage+1 }">下一页</a> 
               			</c:if>
                    </div>
                    <span class="pgb y">
                    	<a href="article.jspx?_method=show&id=${sessionScope.article.id }">返回</a>
                    </span>

                    <a id="newspecial" title="发新帖" href="index.jspx?_method=create&id=${article.blocks.id }" >
                    	<img alt="发新帖" src="images/pn_post.png" />
                    </a>
                    <a id="post_reply" title="回复" href="javascript:gopst();" >
                    	<img alt="回复" src="images/pn_reply.png" />
                    </a>
                    
                </div>
                <!-- 发帖回帖结束 -->
                
                <div class="clear"></div>
                <div style="margin-top: 10px;"></div>
                <!-- 回帖开始 -->
                <div id="f_pst" class="pl bm bmw">
                    <form id="reply_form" action="reply.jspx?_method=save&articleid=${article.id }" method="post" ">
                        <div class="pls" style="float:left; height: 250px;">
                            <div class="avatar">
                            	<c:choose>
                            		<c:when test="${not empty sessionScope.user }">
                            			<img src="upload/${user.headpic }" />
                            		</c:when>
                            		<c:otherwise>
                                		<img src="images/noavatar_middle.gif.jpg" />
                                	</c:otherwise>
                                </c:choose>
                            </div>
                        </div>
                        <div class="plc">
                            <div class="cl">
                            	<input id="repid" type="hidden" name="pid" value="-1"/>
                                <div class="hasfsl" style="margin-right: 10px;">
                                	<label for="content"></label>
                                    <textarea id="content" name="content" class="area"></textarea>
                                </div>
                                <div class="error">
                                	<span id="errormsg"></span>
                                </div>
                                <p class="ptm">
                                	<c:if test="${not empty sessionScope.user }">
                                    	<input type="submit" value="发表回复" class="pn vm"  />
                                    </c:if>
                                    <c:if test="${empty sessionScope.user }">
                                    	请<a style="color: red;" href="index.jspx?_method=login&id=${sessionScope.article.id }&page=${sessionScope.page.currentPage}"> 登陆 </a>后再回复，没有账户？赶快<a style="color: red;" href="index.jspx?_method=register"> 注册 </a>吧！
                                    </c:if>
                                </p>
                            </div>
                        </div>
                    </form>
                    <div class="clear"></div>
                </div>
                <!-- 回帖结束 -->
            </div>
        </div>
    </div>
    <!-- 主体部分结束 -->
    
	<!-- footer开始 -->
	<%@ include file="template/footer.jsp" %>
    <!-- footer结束 -->
   
</body>
</html>

